package cn.rkylin.oms.aftersale.resend.vo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;

import cn.rkylin.oms.aftersale.resend.domain.AfterSaleResend;
import cn.rkylin.oms.aftersale.resend.domain.AfterSaleResendSku;
import cn.rkylin.oms.common.consts.ResendCancelStatus;
import cn.rkylin.oms.common.consts.ResendStatus;

/**
 * 类名:ResendVO <br/>
 * 作用: 系统补发单值类. <br/>
 * 创建原因: 系统补发单值类. <br/>
 * 创建时间: 2017年11月7日 下午8：00：00 <br/>
 * 
 * @author liPeng
 * @version v1.0
 */
public class ResendVO extends AfterSaleResend {

    /**
     * 构造器：ResendVO.
     *
     */
    public ResendVO() {

    }

    /**
     * 序列号Id
     */
    private static final long serialVersionUID = -2692074696495876720L;
    /**
     * 按钮开始
     */
    private static final String OPERATION_BTN_EDIT = "<button onclick=\"operationEdit(this)\" resendId=\"%s\" orderId=\"%s\" type=\"button\" class=\"btn btn-info btn-xs\" pepid='resendEdit'><i class=\"fa fa-edit\"></i>&nbsp;修改</button>";
    private static final String OPERATION_BTN_CANCEL = "<button onclick=\"operationCancel(this)\" resendId=\"%s\" orderId=\"%s\" type=\"button\" class=\"btn btn-danger btn-xs\" pepid='resendCancel'><i class=\"fa fa-times\"></i>&nbsp;取消</button>";
    private static final String OPERATION_BTN_DELETE = "<button onclick=\"operationDelete(this)\" resendId=\"%s\" orderId=\"%s\" type=\"button\" class=\"btn btn-danger btn-xs\" pepid='resendDelete'><i class=\"fa fa-trash-o\"></i>&nbsp;删除</button>";
    private static final String OPERATION_BTN_CHECK = "<button onclick=\"operationCheck(this)\" resendId=\"%s\" orderId=\"%s\" type=\"button\" class=\"btn btn-info btn-xs\" pepid='resendView'><i class=\"fa fa fa-list-alt\"></i>&nbsp;查看</button>";
    /**
     * 按钮结束
     */

    /**
     * 复选框
     */
    private static final String STATUS_CHK = "<input name=\"chkItem\"  type=\"checkbox\" resendId=\"%s\" orderId=\"%s\" /></input>";
    // private static final String STATUS_CHK = "<input name=\"chkItem\"
    // class=\"chkRule icheck\" style=\"display:none;\" type=\"checkbox\"
    // resendId=\"%s\" orderId=\"%s\" /></input>";

    /**
     * resendGoodsList:补发单商品(来自订单)详情列表.
     */
    private List<ResultdSkuVO> resultSkuVOList;

    /**
     * resendGoodsList:补发单商品详情列表.
     */
    private List<AfterSaleResendSku> resendSkuList;

    /**
     * searchCondition:快速查询条件.
     */
    private String quickSearch;

    /**
     * orderBy:排序规则.
     */
    private String orderBy;

    /**
     * 复选框
     */
    private String chk;

    /**
     * operation:操作按钮
     */
    private String operation;

    /**
     * ecTradeCode:平台交易号.
     */
    private String ecTradeCode;

    /**
     * lgstNo:物流单号
     */
    private String lgstNo;

    /**
     * shoptype:店铺类型：淘宝，京东，其他，电话接单，独立商城，渠道采购
     */
    private String shopType;

    /**
     * paidDate:付款日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date paidDate;

    /**
     * 高级查询相关的条件
     */
    /**
     * queryOrderCode:订单编号.
     */
    private String queryOrderCode;
    /**
     * queryShopName:店铺名称.
     */
    private String queryShopName;
    /**
     * queryStorName:发货仓库.
     */
    private String queryStorName;
    /**
     * queryLgstName:补发物流公司.
     */
    private String queryLgstName;
    /**
     * queryDateType:日期类型.
     */
    private String queryDateType;
    /**
     * queryDateStart:开始日期.
     */
    private Date queryDateStart;
    /**
     * queryDateEnd:结束日期.
     */
    private Date queryDateEnd;

    /**
     * tab上补发单状态数据
     */
    /**
     * 待审核记录数
     */
    private Integer countVerify;
    /**
     * 待发货记录数
     */
    private Integer countDeliver;
    /**
     * 已完成记录数
     */
    private Integer countComplete;
    /**
     * 已取消记录数
     */
    private Integer countCancal;

    /**
     * queryResendStatus:补发单状态列表（查询多个补发单状态列表用）
     */
    public List queryResendStatus;

    /**
     * idArray：id列表，用于批量操作
     */
    private List<String> idArray = new ArrayList<String>();

    public List<ResultdSkuVO> getResultSkuVOList() {
        return resultSkuVOList;
    }

    public void setResultSkuVOList(List<ResultdSkuVO> resultSkuVOList) {
        this.resultSkuVOList = resultSkuVOList;
    }

    public List<AfterSaleResendSku> getResendSkuList() {
        return resendSkuList;
    }

    public void setResendSkuList(List<AfterSaleResendSku> resendSkuList) {
        this.resendSkuList = resendSkuList;
    }

    public String getQuickSearch() {
        return quickSearch;
    }

    public void setQuickSearch(String quickSearch) {
        this.quickSearch = quickSearch;
    }

    public String getOrderBy() {
        return orderBy == null ? null : orderBy.replaceAll(".*([';]+|(--)+).*", " ");// 此字段需要防止sql注入
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getChk() {
        return this.chk;
    }

    public void setChk(String chk) {
        this.chk = String.format(STATUS_CHK, this.getResendId(), this.getSourceId()).toString();
    }

    public String getOperation() {
        return operation;
    }

    public void setOperation(String operation) {
        StringBuffer opButton = new StringBuffer();
        if (ResendCancelStatus.N.equals(getCancelStatus())) {
            if (ResendStatus.VERIFY.equalsIgnoreCase(getResendStatus())) {
                // 待审核 ：可以执行修改查看和取消操作
                opButton.append(String.format(OPERATION_BTN_EDIT, getResendId(), getSourceId()));
                opButton.append("&nbsp;");
                opButton.append(String.format(OPERATION_BTN_CHECK, getResendId(), getSourceId()));
                opButton.append("&nbsp;");
                opButton.append(String.format(OPERATION_BTN_DELETE, getResendId(), getSourceId()));
            }
            if (ResendStatus.DELIVER.equalsIgnoreCase(getResendStatus())) {
                // 待发货 ：可以执行查看和取消操作
                opButton.append(String.format(OPERATION_BTN_CHECK, getResendId(), getSourceId()));
                opButton.append("&nbsp;");
                opButton.append(String.format(OPERATION_BTN_CANCEL, getResendId(), getSourceId()));
            }
            if (ResendStatus.COMPLETE.equalsIgnoreCase(getResendStatus())) {
                // 已完成 ：可以执行查看操作
                opButton.append(String.format(OPERATION_BTN_CHECK, getResendId(), getSourceId()));
            }
        }
        if (ResendCancelStatus.Y.equals(getCancelStatus())) {
            // 已取消：可以执行查看操作
            opButton.append(String.format(OPERATION_BTN_CHECK, getResendId(), getSourceId()));
        }

        this.operation = opButton.toString();
    }

    public String getEcTradeCode() {
        return ecTradeCode;
    }

    public void setEcTradeCode(String ecTradeCode) {
        this.ecTradeCode = ecTradeCode;
    }

    public String getLgstNo() {
        return lgstNo;
    }

    public void setLgstNo(String lgstNo) {
        this.lgstNo = lgstNo;
    }

    public String getShopType() {
        return shopType;
    }

    public void setShopType(String shopType) {
        this.shopType = shopType;
    }

    public Date getPaidDate() {
        return paidDate;
    }

    public void setPaidDate(Date paidDate) {
        this.paidDate = paidDate;
    }

    public String getQueryOrderCode() {
        return queryOrderCode;
    }

    public void setQueryOrderCode(String queryOrderCode) {
        this.queryOrderCode = queryOrderCode;
    }

    public String getQueryShopName() {
        return queryShopName;
    }

    public void setQueryShopName(String queryShopName) {
        this.queryShopName = queryShopName;
    }

    public String getQueryStorName() {
        return queryStorName;
    }

    public void setQueryStorName(String queryStorName) {
        this.queryStorName = queryStorName;
    }

    public String getQueryLgstName() {
        return queryLgstName;
    }

    public void setQueryLgstName(String queryLgstName) {
        this.queryLgstName = queryLgstName;
    }

    public String getQueryDateType() {
        return queryDateType;
    }

    public void setQueryDateType(String queryDateType) {
        this.queryDateType = queryDateType;
    }

    public Date getQueryDateStart() {
        return queryDateStart;
    }

    public void setQueryDateStart(Date queryDateStart) {
        this.queryDateStart = queryDateStart;
    }

    public Date getQueryDateEnd() {
        return queryDateEnd;
    }

    public void setQueryDateEnd(Date queryDateEnd) {
        this.queryDateEnd = queryDateEnd;
    }

    public Integer getCountVerify() {
        return countVerify;
    }

    public void setCountVerify(Integer countVerify) {
        this.countVerify = countVerify;
    }

    public Integer getCountDeliver() {
        return countDeliver;
    }

    public void setCountDeliver(Integer countDeliver) {
        this.countDeliver = countDeliver;
    }

    public Integer getCountComplete() {
        return countComplete;
    }

    public void setCountComplete(Integer countComplete) {
        this.countComplete = countComplete;
    }

    public Integer getCountCancal() {
        return countCancal;
    }

    public void setCountCancal(Integer countCancal) {
        this.countCancal = countCancal;
    }

    public List getQueryResendStatus() {
        return queryResendStatus;
    }

    public void setQueryResendStatus(List queryResendStatus) {
        this.queryResendStatus = queryResendStatus;
    }

    public List<String> getIdArray() {
        return idArray;
    }

    public void setIdArray(List<String> idArray) {
        this.idArray = idArray;
    }
    private Integer count ;

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }
}
